import React from 'react';
import { Router, Route, IndexRoute, Redirect } from 'dva/router';

import Error404 from './routes/Error404';
import IndexPage from './routes/index/IndexPage';

import AdminLoginPage from './routes/admin/login/AdminLoginPage';
import AdminHomePage from './routes/admin/home/AdminHomePage';

import ASUserPage from './routes/admin/_system/ASUserPage';


function RouterConfig({ history }) {
  return (
    <Router history={history}>
      <Route path="/" component={IndexPage} />
      <Route path="/">
        {/* 默认 */}
        <IndexRoute component={IndexPage} />
        <Route path="admin">
          <Route path="login" component={AdminLoginPage} />
          <Route path="home" component={AdminHomePage} />

          <Route path="system">
            <Route path="user" component={ASUserPage} />
          </Route>
        </Route>
        {/* 404 */}
        <Route path="404" component={Error404} />
        {/* 其他重定向到 404 */}
        <Redirect from="*" to="/404" />
      </Route>
    </Router>
  );
}

export default RouterConfig;
